package com.zhl.resoutce;

import java.io.*;

public class Test3 {
    public static void main(String[] args){
        try(
                //1。复制照片
            InputStream is = new FileInputStream("src/Copy1.png");
            //2.创建一个字节输出流管道
            OutputStream os = new FileOutputStream("src/com/zhl/byte_stream4/photo_copy.png");
            )
        {
            //3.创建字节数组，复负责转移字节数据
            byte[] buffer = new byte[1024];   //1kb

            //4.从字节输入流中读取数据，写出去到字节输出流中，读多少写多少
            int len;
            while ((len = is.read(buffer))!= -1) {
                os.write(buffer, 0, len);
            }
            System.out.println("复制成功！");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


    }
}
